﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace AfterlifeLib.Projectiles
{
    //  -135 180 135
    //      \ | /
    // -90 <- O -> 90
    //      / | \
    //    -45 0  45

    public class Projectile
    {
        public string particleEffect;

        public bool active;

        public Vector2 position;

        public Vector2 velocity;

        public float speed;

        public float angle;

        public float length = 15f;

        public Projectile()
        {
            
        }

        public void Initialize(Vector2 position, float angle, float speed, string particleEffect)
        {
            this.active = true;
            this.position = position;
            this.angle = angle;
            this.speed = speed;
            this.velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
            this.particleEffect = particleEffect;
        }

        public void Update(float delta)
        {
            position += (velocity * speed) * delta;
        }

        public void Draw(PrimitiveBatch primitiveBatch, Camera2D camera)
        {
            primitiveBatch.AddVertex(position - camera.Position, Color.Orange);
            primitiveBatch.AddVertex(position + (velocity * length) - camera.Position, Color.Orange);
        }
    }
}
